import React, { Component } from 'react';
import { Button, message } from 'antd';

import { withRouter } from 'react-router-dom'

const error = (msg) => {
    message.error(msg);
};

class JoinButton extends Component {
    handleLastTime = (lastTime) => {
        console.log(lastTime);
        var today = new Date();
        console.log(today.getTime().toString());
        if (today.getTime()>lastTime) {
            error('活动已结束');
            return;
        }else {
            this.props.history.push('/question');
        }
    }

    render() {
        return (
            <Button
                type="primary"
                style={{
                    width: 100,
                    height: 40,
                    position: 'relative',
                    left: '50%',
                    marginLeft: -50,
                    marginTop: 50,
                    marginBottom: 50
                }}
                onClick={() => this.handleLastTime(this.props.lastTime)}
            >
                参加活动
            </Button>
        );
    }
}

export default withRouter(JoinButton);